#ifndef SLAVE_PROTOCOL_H_
#define SLAVE_PROTOCOL_H_
#include "../base/conf.h"

C_CODE_BEGIN
struct message;
struct slave_protocol {
	const char* slavename;
	int (*init)(void*);
	void (*notify)( struct slave_api* , void* );
	void (*cb) ( struct message* msg , void* arg , struct slave_api* api );
	void (*clean)( void* );
	void* argument;
};

/*
 * The following API collection is the behavior protocol between
 * master and slave. The slave should use the following API to
 * compose its internal functionality through facilitating slave
 * master framework. 
 */
struct slave_api {
	/*
	* This interface is used to send message to target slave.
	* The message structure will wrap all the message content
	* except the session ID which will be generated automatically.
	* The another API is the slave_api object itself, indeed this
	* object internally hidden a unique id of the slave which is
	* used to fetch the slave object.
	*/
	size_t (*sendmessage)( struct message* msg , const char* dest , struct slave_api* sl );
};

C_CODE_END

#endif // SLAVE_PROTOCOL_H_